//
//  StatusForwardCell.swift
//  我的微博
//
//  Created by Creator on 15/10/17.
//  Copyright © 2015年 Creator. All rights reserved.
//

import UIKit

class StatusForwardCell: StatusCell {


  override  var status: Status? {
        didSet {
            
            let name = status?.retweeted_status?.user?.name ?? ""
            let text = status?.retweeted_status?.text ?? ""
            
            forwardLable.text = "@" + name + ":" + text
        
        }
    
    }
    
    
    override func setupUI() {
        super.setupUI()
        
        // 添加控件
        contentView.insertSubview(backButton, belowSubview: pictureView)
        contentView.insertSubview(forwardLable, aboveSubview: backButton)
        
        // 测试
        
        // 自动布局
        // 图片按钮
        backButton.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: contentLable, size: nil, offset: CGPoint(x: -8, y: 8))
        backButton.ff_AlignVertical(type: ff_AlignType.TopRight, referView: bottomView, size: nil)
        
        // 转发文字
        forwardLable.ff_AlignInner(type: ff_AlignType.TopLeft, referView: backButton, size: nil, offset: CGPoint(x: 8, y: 8))
        
        // 配图视图
        let cons = pictureView.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: forwardLable, size: CGSize(width: 290, height: 290), offset: CGPoint(x: 0, y: 8.0))
        pictureWidthCons = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Width)
        pictureHeighCons = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Height)
        pictureTopCons = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Top)

    }
    
    
    // MARK: 懒加载
    private lazy var forwardLable: UILabel = {
    
        let label = UILabel(color: UIColor.darkGrayColor(), fontSize: 14)
        
        label.preferredMaxLayoutWidth = UIScreen.mainScreen().bounds.width - 2 * 8
        label.numberOfLines = 0
        
        return label
    }()
    
    private lazy var backButton: UIButton = {
    
        let btn = UIButton()
        
        btn.backgroundColor = UIColor(white: 0.9, alpha: 1.0)
        
        return btn
    }()
    

}
